<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="jakarta.tags.core" %>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>医生工作台</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Microsoft YaHei', sans-serif;
        }
        
        body {
            background-color: #f5f5f5;
            min-height: 100vh;
        }
        
        .header {
            background-color: #4a90e2;
            color: white;
            padding: 15px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .header h1 {
            font-size: 24px;
        }
        
        .header .user-info {
            display: flex;
            align-items: center;
        }
        
        .header .user-info span {
            margin-right: 15px;
        }
        
        .header .logout-btn {
            color: white;
            text-decoration: none;
            padding: 5px 10px;
            background-color: rgba(255,255,255,0.2);
            border-radius: 4px;
            transition: background-color 0.3s;
        }
        
        .header .logout-btn:hover {
            background-color: rgba(255,255,255,0.3);
        }
        
        .container {
            display: flex;
            min-height: calc(100vh - 60px);
        }
        
        .sidebar {
            width: 200px;
            background-color: #333;
            color: white;
        }
        
        .sidebar ul {
            list-style: none;
        }
        
        .sidebar li {
            padding: 15px 20px;
        }
        
        .sidebar a {
            color: white;
            text-decoration: none;
            display: block;
            transition: background-color 0.3s;
        }
        
        .sidebar li:hover {
            background-color: #4a90e2;
        }
        
        .sidebar li.active {
            background-color: #4a90e2;
        }
        
        .content {
            flex: 1;
            padding: 20px;
        }
        
        .dashboard-cards {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        
        .card {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            padding: 20px;
        }
        
        .card h3 {
            margin-bottom: 15px;
            color: #333;
            border-bottom: 1px solid #eee;
            padding-bottom: 10px;
        }
        
        .appointment-list {
            list-style: none;
        }
        
        .appointment-item {
            padding: 10px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .appointment-item:last-child {
            border-bottom: none;
        }
        
        .appointment-info {
            flex: 1;
        }
        
        .appointment-time {
            font-weight: bold;
            color: #4a90e2;
        }
        
        .view-btn {
            background-color: #4a90e2;
            color: white;
            border: none;
            padding: 5px 10px;
            border-radius: 4px;
            cursor: pointer;
            text-decoration: none;
        }
        
        .view-btn:hover {
            background-color: #357abD;
        }
        
        .empty-message {
            text-align: center;
            color: #999;
            padding: 20px;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>医生工作台</h1>
        <div class="user-info">
            <span>欢迎您，${loginDoctor.doctorName}</span>
            <a href="/doctorLogout" class="logout-btn">退出登录</a>
        </div>
    </div>
    
    <div class="container">
        <div class="sidebar">
            <ul>
                <li class="active"><a href="/doctor/workspace">工作台</a></li>
                <li><a href="/doctor/appointments">我的排班</a></li>
                <li><a href="/doctor/patients">病人管理</a></li>
            </ul>
        </div>
        
        <div class="content">
            <div class="dashboard-cards">
                <!-- 今日排班卡片 -->
                <div class="card">
                    <h3>今日排班</h3>
                    <ul class="appointment-list">
                        <c:choose>
                            <c:when test="${not empty todayAppointments}">
                                <c:forEach items="${todayAppointments}" var="appointment">
                                    <li class="appointment-item">
                                        <div class="appointment-info">
                                            <div class="appointment-time">${appointment.appointmentTime}</div>
                                            <div>科室：${appointment.departmentName}</div>
                                            <div>状态：${appointment.status == 0 ? '待预约' : '已预约'}</div>
                                        </div>
                                        <a href="/doctor/appointments" class="view-btn">查看</a>
                                    </li>
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                                <li class="empty-message">今日暂无排班</li>
                            </c:otherwise>
                        </c:choose>
                    </ul>
                </div>
                
                <!-- 待处理病人卡片 -->
                <div class="card">
                    <h3>待处理病人</h3>
                    <ul class="appointment-list">
                        <c:choose>
                            <c:when test="${not empty pendingVisits}">
                                <c:forEach items="${pendingVisits}" var="visit">
                                    <li class="appointment-item">
                                        <div class="appointment-info">
                                            <div>姓名：${visit.userName}</div>
                                            <div>预约时间：${visit.appointmentTime}</div>
                                            <div>症状：${visit.symptom}</div>
                                        </div>
                                        <a href="/doctor/medicalRecord/write?visitId=${visit.visitId}" class="view-btn">写病历</a>
                                    </li>
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                                <li class="empty-message">暂无待处理病人</li>
                            </c:otherwise>
                        </c:choose>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</body>
</html>